package pe.bn.service.interfaz;

public class GatewayInterfaceProxy implements pe.bn.service.interfaz.GatewayInterface {
  private boolean _useJNDI = true;
  private String _endpoint = null;
  private pe.bn.service.interfaz.GatewayInterface gatewayInterface = null;
  
  public GatewayInterfaceProxy() {
    _initGatewayInterfaceProxy();
  }
  
  private void _initGatewayInterfaceProxy() {
  
  if (_useJNDI) {
    try{
      javax.naming.InitialContext ctx = new javax.naming.InitialContext();
      gatewayInterface = ((pe.bn.service.interfaz.GatewayInterfaceService)ctx.lookup("java:comp/env/service/GatewayInterfaceService")).getGatewayInterface();
      }
    catch (javax.naming.NamingException namingException) {}
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  if (gatewayInterface == null) {
    try{
      gatewayInterface = (new pe.bn.service.interfaz.GatewayInterfaceServiceLocator()).getGatewayInterface();
      }
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  if (gatewayInterface != null) {
    if (_endpoint != null)
      ((javax.xml.rpc.Stub)gatewayInterface)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
    else
      _endpoint = (String)((javax.xml.rpc.Stub)gatewayInterface)._getProperty("javax.xml.rpc.service.endpoint.address");
  }
  
}


public void useJNDI(boolean useJNDI) {
  _useJNDI = useJNDI;
  gatewayInterface = null;
  
}

public String getEndpoint() {
  return _endpoint;
}

public void setEndpoint(String endpoint) {
  _endpoint = endpoint;
  if (gatewayInterface != null)
    ((javax.xml.rpc.Stub)gatewayInterface)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
  
}

public pe.bn.service.interfaz.GatewayInterface getGatewayInterface() {
  if (gatewayInterface == null)
    _initGatewayInterfaceProxy();
  return gatewayInterface;
}

public pe.bn.service.bean.ResponseGateway enviarTramaConsulta(pe.bn.service.bean.RequestGateway request) throws java.rmi.RemoteException{
  if (gatewayInterface == null)
    _initGatewayInterfaceProxy();
  return gatewayInterface.enviarTramaConsulta(request);
}


}